home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94a.txt / 000093_icon-group-sender _Fri Apr 22 13:06:56 1994.msg < prev    next >
Internet Message Format  |  1994-08-19  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Fri, 22 Apr 1994 09:14:03 MST
  2. Date: Fri, 22 Apr 1994 13:06:56 +0100
  3. From: Jan Peter de Ruiter <janpeter@mpi.nl>
  4. Message-Id: <9404221206.AA25564@mpix10.mpi.kun.nl>
  5. To: icon-group@cs.arizona.edu
  6. Subject: is this a bug?
  7. Status: R
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9.  
  10. Hi Icon folks,
  11.  
  12. I hope someone can help me out with this.
  13.  
  14. I had a terrible bug in a program, and it was caused
  15. by the following phenomenon:
  16.  
  17. ------- example program -------------
  18. link ximage
  19. procedure main()
  20.     t := table([]) # a table with default element []
  21.     every put(t[1],generate(1,5)) # fill t[1], which is empty list
  22.     every put(t[2],generate(6,9)) # fill t[2], which is empty list
  23.     every(write(!t[1])) # write out all elements of t[1]
  24.     write()
  25.     every(write(!t[2])) # write out all elements of t[2]
  26.     write(ximage(t)) # write out image of t 
  27. end
  28.  
  29. procedure generate(a,b)
  30.     every suspend (a to b)
  31. end
  32.  
  33. -------- end example program -----------
  34.  
  35. Now I expected that t[1] would be [1,2,3,4,5] and 
  36. t[2] would be [6,7,8,9]. However, the output was:
  37.  
  38. --------- program output ---------------
  39.  
  40. 1
  41. 2
  42. 3
  43. 4
  44. 5
  45. 6
  46. 7
  47. 8
  48. 9
  49.  
  50. 1
  51. 2
  52. 3
  53. 4
  54. 5
  55. 6
  56. 7
  57. 8
  58. 9
  59. T1 := table({L1 := list(9)
  60.          L1[1] := 1
  61.          L1[2] := 2
  62.          L1[3] := 3
  63.          L1[4] := 4
  64.          L1[5] := 5
  65.          L1[6] := 6
  66.          L1[7] := 7
  67.          L1[8] := 8
  68.          L1[9] := 9
  69.       L1})
  70. --------- end program output -------------
  71. It seems there is actually one list here, with
  72. both t[1] and t[2] pointing to it. This was
  73. not what I expected.
  74.  
  75. Now my question is: have I understood the icon
  76. semantics wrongly, or is this a bug? If anyone
  77. understands what is happening here, could (s)he
  78. please explain?
  79.  
  80. Thanks in advance,
  81.  
  82. Jan
  83.  
  84. janpeter@mpi.kun.nl
  85.